package logic

import (
	"context"
	"encoding/json"
	"log"
	"three-sxp/models/mysql"

	"three-sxp/goodsrpc/goodsrpc"
	"three-sxp/goodsrpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShowProductLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewShowProductLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowProductLogic {
	return &ShowProductLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// ShowProduct todo: 预热商品展示
func (l *ShowProductLogic) ShowProduct(in *goodsrpc.ShowProductRequest) (*goodsrpc.ShowProductResponse, error) {
	// todo: add your logic here and delete this line
	res, _ := mysql.GetProductAll()
	log.Println(res, "88888888888888888888888888")
	p, _ := json.Marshal(res)
	return &goodsrpc.ShowProductResponse{
		Code: 200,
		Msg:  "查询成功",
		Data: string(p),
	}, nil
}
